package com.appclient;
 
import configurationReader.ConfigReader;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class Start extends Application{
    public static Stage stage;
    public static Scene mainScene;
    public static MainPanelController mainPanelController;
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage stage) {
        Parent root = null;
        ConfigReader.loadConfigFile();
        URL location = getClass().getClassLoader().getResource("page.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader(location);
        Scene loginScene = null;
        try {
            root = (Parent) fxmlLoader.load();
            FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("loginPanel.fxml"));
            stage.getIcons().add(new Image("http://www.leics.gov.uk/parking_icon.jpg"));
            AnchorPane page = (AnchorPane) loader.load();
            loginScene = new Scene(page);
        } catch (IOException ex) {
            Logger.getLogger(Start.class.getName()).log(Level.SEVERE, "[CarPark] Cannot load JavaFX FXML page structure", ex);
        }
        this.stage = stage;
        mainScene = new Scene(root);
        mainPanelController = fxmlLoader.getController();
        stage.setScene(loginScene);
        stage.show();
    }
    
}
